package com.orange.common.web.exception;


import com.orange.common.web.common.AppHttpCodeEnum;
import com.orange.common.web.vo.ResponseResult;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:全局异常处理类
 * 对异常进行拦截并且进行处理
 * @Author: orange
 */
@ControllerAdvice
public class ExceptionHandle {

    /**
     * @Description:对业务异常统一处理
     */
    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public ResponseResult businessExceptionHandler(BusinessException e){
        return ResponseResult.errorResult(e.getCode(),e.getMessage());
    }

    /**
     * @Description:对系统异常统一处理
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResponseResult exceptionHandler(Exception e){
        return ResponseResult.errorResult(AppHttpCodeEnum.SYSTEMERROR.getCode(),AppHttpCodeEnum.SYSTEMERROR.getErrorMessage());
    }
}
